package lowijs.XfireClient;

import java.util.*;

public class ConversationManager {
	private final ArrayList<Conversation> convos =
		new ArrayList<Conversation>();
	private static ConversationManager cm = null;
	
	protected ConversationManager() {
		
	}
	
	public static ConversationManager getInstance() {
		if (cm == null)
			cm = new ConversationManager();
		return cm;
	}
	
	public void cleanup() {
		convos.clear();
		cm = null;
	}
	
	public boolean conversationExists(Friend f) {
		for (Conversation cv : convos) {
			if (cv.getFriend() == f)
				return true;
		}
		return false;
	}
	
	public Conversation getConversation(Friend f) {
		for (Conversation cv : convos) {
			if (cv.getFriend() == f)
				return cv;
		}
		Conversation cv = new Conversation(f);
		convos.add(cv);
		return cv;
	}
}
